package cn.sdack.go.common.entities.users;

import cn.sdack.go.common.entities.BaseEntity;
import cn.sdack.go.common.entities.PermissionEntity;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.hibernate.validator.constraints.Length;

/**
 * 角色
 * @author sdack
 * @date 2024/1/8
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "roles", indexes = {
        @Index(name = "idx_roles_code",columnList = "code", unique = true)
})
public class RoleEntity extends PermissionEntity {

    @NotNull(message = "角色ID - 必填",groups = {BaseEntity.Set.class})
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    // 英文标签
    @NonNull
    @NotNull(message = "权限code - 必填",groups = {BaseEntity.Add.class,BaseEntity.Set.class})
    @Length(min = 3,max = 150,message = "权限key - 长度不正确",groups = {BaseEntity.Add.class,BaseEntity.Set.class})
    @Column(length = 50, nullable = false)
    private String code;

    //中文 描述
    @NonNull
    @NotNull(message = "名称 - 必填",groups = {BaseEntity.Add.class,BaseEntity.Set.class})
    @Length(min = 3,max = 150,message = "名称 - 长度不正确",groups = {BaseEntity.Add.class,BaseEntity.Set.class})
    @Column(length = 50,nullable = false)
    private String name;



}
